package com.r2coding.log.controller;

import com.github.pagehelper.PageInfo;
import com.r2coding.common.util.Result;
import com.r2coding.log.entity.LogEntity;
import com.r2coding.log.service.LogService;
import com.r2coding.log.vo.QueryLogReqVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

/**
 * 
 *
 * @author 98k灬
 * @email hk666zx@163.com
 * @date 2022-05-26 22:10:59
 */
@RestController
@RequestMapping("/api/log")
public class LogController {
    @Autowired
    private LogService logService;

    /**
     * 查询分页列表
     *
     * @param vo 请求信息
     * @return 统一响应体
     */
    @PostMapping("/list")
    public Result list(@RequestBody QueryLogReqVo vo) {
        PageInfo<LogEntity> page = logService.queryList(vo);
        return Result.ok(page);
    }

    /**
     * 删除
     */
    @PreAuthorize("hasAuthority('log:delete')")
    @DeleteMapping("/delete/{id}")
    public Result delete(@PathVariable("id") Integer id){
		logService.removeById(id);
        return Result.ok();
    }
}
